package com.ayu.gtest.javaClass;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by guoyongliang on 2018/8/29.
 */
public class DynamicProxyHandler implements InvocationHandler {
    private Object proxied;
    public DynamicProxyHandler(Object proxied){
        this.proxied=proxied;
    }
    public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable {
        System.out.println("proxy: "+proxy.getClass()+".method: "+method+",args: "+args);
        if(args!=null)
            for(Object arg : args)
                System.out.println("  "+arg);
        return method.invoke(proxied, args);
    }
}
